<p>Trilium is an offline-first note-taking application that stores all data
  locally on the desktop client. However, it also offers the option to set
  up synchronization with a server instance, allowing multiple desktop clients
  to sync with a central server. This creates a star-shaped topology:</p>
<p>
  <img src="Synchronization_image.png">
</p>
<p>In this setup, a central server (referred to as the <em>sync server</em>)
  and multiple <em>client</em> (or <em>desktop</em>) instances synchronize with
  the sync server. Once configured, synchronization is automatic and ongoing,
  requiring no manual intervention.</p>
<h2>Setting Up Synchronization</h2>
<h3>Security Considerations</h3>
<p>Setting up the server securely is critical and can be complex. It is crucial
  to use a valid <a href="#root/_help_l2VkvOwUNfZj">TLS certificate</a> (HTTPS)
  rather than an unencrypted HTTP connection to ensure security and avoid
  potential vulnerabilities.</p>
<h3>Synchronizing a Desktop Instance with a Sync Server</h3>
<p>This method is used when you already have a desktop instance of Trilium
  and want to set up a sync server on your web host.</p>
<ol>
  <li><strong>Server Deployment</strong>: Ensure your server instance is deployed
    but uninitialized.</li>
  <li><strong>Desktop Configuration</strong>: Open your desktop instance, navigate
    to Options -&gt; Sync tab -&gt; Sync configuration, and set the "Server
    instance address" to your sync server's address. Click Save.</li>
</ol>
<p>
  <img src="Synchronization_sync-confi.png" alt="screenshot of the sync settings options modal">
</p>
<ol>
  <li><strong>Testing Sync</strong>: Click the "Test sync" button to verify
    the connection to the sync server. If successful, the client will start
    pushing all data to the server instance. This process may take some time,
    but you can continue using Trilium. Periodically check the server instance
    to confirm when the sync is complete. Once finished, you should see the
    login screen on the server.</li>
</ol>
<h3>Synchronizing a Desktop Instance from a Sync Server</h3>
<p>This method is used when you already have a sync server and want to configure
  a new desktop instance to sync with it.</p>
<ol>
  <li><strong>Desktop Setup</strong>: Follow the <a href="#root/_help_poXkQfguuA0U">desktop installation page</a>.</li>
  <li><strong>Initial Configuration</strong>: When prompted, choose the option
    to set up sync with a sync server.</li>
</ol>
<p>
  <img src="Synchronization_sync-init.png" alt="screenshot of the sync from server setup page">
</p>
<ol>
  <li><strong>Server Details</strong>: Configure the Trilium server address
    and enter the correct username and password for authentication.</li>
  <li><strong>Finish Setup</strong>: Click the "Finish setup" button. If successful,
    you will see the following screen:</li>
</ol>
<p>
  <img src="Synchronization_sync-in-pr.png" alt="screenshot of the sync page">
</p>
<p>Once synchronization is complete, you will be automatically redirected
  to the Trilium application.</p>
<h2>Proxy Configuration</h2>
<p>Two proxy setups are supported:</p>
<ul>
  <li><strong>Explicit Proxy Configuration</strong>: Set the proxy server in
    Options / Sync. Only unauthenticated proxy servers are supported.</li>
  <li><strong>System Proxy Settings</strong>: If no proxy server is explicitly
    configured, Trilium will use the system proxy settings.</li>
</ul>
<h2>Troubleshooting</h2>
<h3>Date/Time Synchronization</h3>
<p>For successful synchronization, both client and server must have the same
  date and time, with a tolerance of up to five minutes.</p>
<h3>Certificate Issues</h3>
<p>When using TLS, Trilium will verify the server certificate. If verification
  fails (e.g., due to self-signed certificates or certain corporate proxies),
  you can run the Trilium client with the <code>NODE_TLS_REJECT_UNAUTHORIZED</code> environment
  variable set to <code>0</code>:</p><pre><code class="language-text-x-trilium-auto">export NODE_TLS_REJECT_UNAUTHORIZED=0</code></pre>
<p>This will disable TLS certificate verification, significantly reducing
  security and exposing the setup to MITM attacks. It is strongly recommended
  to use a valid signed server certificate. Newer Trilium versions include
  a script called <code>trilium-no-cert-check.sh</code> for this purpose.</p>
<h3>Conflict Resolution</h3>
<p>If you edit the same note on multiple instances before synchronization,
  Trilium resolves conflicts by retaining the newer change and discarding
  the older one. The older version remains accessible in <a href="#root/_help_vZWERwf8U3nx">note revisions</a>,
  allowing data recovery if needed.</p>
<h3>Hash Check</h3>
<p>After each synchronization, Trilium computes a hash of all synced data
  on both the client and the sync server. If there is a discrepancy, Trilium
  will automatically initiate a recovery mechanism to resolve the issue.</p>